package com.linkwedo.saas.project;

import java.util.List;

import com.linkwedo.saas.domain.Project;
import com.linkwedo.saas.domain.Task;

public class TaskService {
	private TaskDao taskDao;

	public TaskDao getTaskDao() {
		return taskDao;
	}

	public void setTaskDao(TaskDao taskDao) {
		this.taskDao = taskDao;
	}

	public Task getTask(Task task) {
		List<Task> uList = getTaskDao().findByExample(task);
		return uList.get(0);
	}
	
	public void save(Task transientInstance) {		
		try {
			getTaskDao().save(transientInstance);		
		} catch (RuntimeException re) {			
			throw re;
		}
	}
	
	public List findAll() {		
		try {
			return getTaskDao().findAll();
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	
	public List findByProjectID(Integer projectId) {		
		try {
			return getTaskDao().findByProjectId(projectId);
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	public void deleteById(Integer pid) {		
		try {
			Task transientInstance = getTaskDao().findById(pid);
			transientInstance.setId(pid);
			getTaskDao().delete(transientInstance);		
		} catch (RuntimeException re) {			
			throw re;
		}
	}
	
	
}
